﻿@{
    ViewData["Title"] = "设备档案检索";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />

    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-left: 5px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }

        #dSearch table tr td {
            padding: 8px;
        }

        #dSearch .input-group {
            width: 100%;
            margin-bottom: 16px;
        }

        #dSearch .input-group-addon {
            width: 100px;
        }

        #dSearch .fix-border {
            border-left: none;
            border-right: none;
        }
    </style>
}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>设备档案信息</h5>
                    <div class="ibox-tools">
                        <a class="btn btn-primary btn-circle btn-outline" title="刷新" href="javascript:location.href=location.href;" style="margin-top: -7px;"><i class=" fa fa-refresh"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="dSearch">
                        <input id="txtSearch" name="txtSearch" class="form-control" placeholder="档案名称" style="width: 195px; float: left" />
                        <a id="search" class="btn btn-sm btn-primary" onclick="getTEquipmentList()"><i class="icon-search"></i>&nbsp;快速检索</a>
                        <a id="ShowSearch" class="btn btn-sm btn-primary" style="display: none" onclick="ShowDivOfPage('#myModal','综合检索',500,510)"><i class="icon-search"></i>&nbsp;综合检索</a>
                        <asp:LinkButton ID="LinkButton1" runat="server" CssClass="btn btn-sm btn-primary" OnClick="lbtnAll_Click"><i class="icon-table"></i>&nbsp;查看全部</asp:LinkButton>
                    </div>
                    <div id="toolbar" style="float: left; margin-left: -195px; margin-top: 10px;">
                    </div>
                    <table id="tabData" class="table table-bordered" style="width: 2250px;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>项目号</th>
                                <th>案卷号</th>
                                <th>实体分类号</th>
                                <th>案卷档号</th>
                                <th>档案名称</th>
                                <th>保管单位名称</th>
                                <th>编制单位</th>
                                <th>编制日期</th>
                                <th>归档年度</th>
                                <th>全宗号</th>
                                <th>保管期限</th>
                                <th>文件开始时间</th>
                                <th>文件结束时间</th>
                                <th>归档日期</th>
                                <th>总页数</th>
                                <th>总件数</th>
                                <th>密级</th>
                                <th>存放位置</th>
                                <th>备注</th>
                                <th>添加时间</th>
                            </tr>
                        </thead>
                    </table>
                    <hr style="height: 1px; border: none; border-top: 1px dashed #1E90FF; margin-top: 3px; margin-bottom: 5px;" />
                    <table id="tabData2" class="table table-bordered" style="min-width: 2700px;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>案卷级档号</th>
                                <th>案卷档号</th>
                                <th>顺序号</th>

                                <th>题名</th>
                                <th>责任制者</th>
                                <th>主题词</th>
                                <th>文件形成时间</th>
                                <th>页数</th>
                                <th>归档日期</th>
                                <th>全宗号</th>
                                <th>归档年度</th>
                                <th>项目号</th>
                                <th>实体分类号</th>
                                <th>保管期限</th>
                                <th>案卷号</th>
                                <th>文件编号</th>
                                <th>页号</th>
                                <th>临时号</th>
                                <th>密级</th>
                                <th>存放位置</th>
                                <th>组卷标识</th>
                                <th>备注</th>
                                <th>添加时间</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div id="myModal" style="display: none;">
        <div id="dSearch" class="modal-body" style="height: 415px;">
            <div class="input-group">
                <span class="input-group-addon">项目号</span>
                <asp:TextBox ID="txtXMH" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">项目名称</span>
                <asp:TextBox ID="txtTitle" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">立项时间</span>
                <asp:TextBox ID="txtReturnYear1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyy'})"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtReturnYear2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyy'})"></asp:TextBox>
            </div>

            <div class="input-group">
                <span class="input-group-addon">开工时间</span>
                <asp:TextBox ID="txtStartDate1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" dataType="int" Msg="文件开始时间格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtStartDate2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" dataType="int" Msg="文件开始时间格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">竣工时间</span>
                <asp:TextBox ID="txtEndDate1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" dataType="int" Msg="文件结束时间格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtEndDate2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" dataType="int" Msg="文件结束时间格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">密级</span>
                <asp:DropDownList ID="ddlSecretLevel" runat="server" CssClass="form-control"></asp:DropDownList>
            </div>

            <div class="input-group">
                <span class="input-group-addon">案卷数</span>
                <asp:TextBox ID="txtPageCount1" runat="server" CssClass="form-control" dataType="zzs" Msg="案卷数格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtPageCount2" runat="server" CssClass="form-control" dataType="zzs" Msg="案卷数格式不正确!"></asp:TextBox>
            </div>

            <div class="input-group">
                <span class="input-group-addon">设计单位</span>
                <asp:TextBox ID="txtDanWei1" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">建设单位</span>
                <asp:TextBox ID="txtDanWei2" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">审批单位</span>
                <asp:TextBox ID="txtDanWei3" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">施工单位</span>
                <asp:TextBox ID="txtDanWei4" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group" style="margin-bottom: 0px;">
                <span class="input-group-addon">备注</span>
                <asp:TextBox ID="txtRemark" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="btnSearch" runat="server" CssClass="btn btn-primary btn-sm" OnClientClick="return verfic('tip', '#dSearch');" OnClick="btnSearch_Click" Text="检索" />
            <input id="btnClose" type="button" class="btn btn-default btn-sm" value="取消" onclick="CloseDiv()" />
        </div>
    </div>
</form>
@section scripts{
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/verification.js"></script>
    <script src="/js/zuiCode.js"></script>
    <script src="../js/store.js"></script>

    <script type="text/javascript">
        var tabHeight = 0;
        $(function () {
            tabHeight = (GetHeight() - 140) / 2//将两个表格平分高
            //var tabHeight = document.documentElement.clientHeight - 100;
            BindTab2("");
            $('#tabData').bootstrapTable({
                height: tabHeight + 50,
                url: "ashx/TEquipment.ashx",
                //data: JSON.parse($("#dJson").text()),
                dataType: "json",
                pagination: true,	//在表格底部显示分页工具栏
                pageSize: 20,  //分页条数
                pageNumber: '1',    //初始化加载第一页，默认第一页
                pageList: [20, 50, 100, 200, 500],
                queryParamsType: 'limit',
                toolbar: '#toolbar',//工具按钮用哪个容器
                silent: true,  //刷新事件必须设置
                buttonsClass: "sm btn-white",//按钮class
                clickToSelect: true,//设置true将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                queryParams: queryParams,//查询参数
                sidePagination: 'server', //服务端
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: true,//是否显示行间隔色
                exportOptions: {
                    ignoreColumn: [0],  //忽略某一列的索引
                },
                responseHandler: function (msg) { //数据加载转换
                    if (msg.result == 1) {
                        return {
                            "total": msg.totalCount,//总页数
                            "rows": JSON.parse(msg.jsonData) //数据
                        };
                    }
                    else {
                        showTip("数据加载失败！", 2);
                    }
                },
                columns: [
                    { align: 'center', width: "50px", checkbox: true },
                    { field: 'XMH', align: 'center', width: "100px", sortable: true },
                    { field: 'AJH', align: 'left', width: "100px", sortable: true },
                    { field: 'STFLH', align: 'center', width: "100px", sortable: true },
                    { field: 'AJDH', align: 'center', width: "100px", sortable: true },
                    //  { field: 'DAMC', align: 'center', width: "200px", sortable: true, formatter: operateOpinionFormatter },
                    { field: 'DAMC', align: 'center', width: "200px", sortable: true },
                    { field: 'BGDWMC', align: 'left', width: "100px", sortable: true },
                    { field: 'BZDW', align: 'center', width: "100px", sortable: true },
                    { field: 'BZRQ', align: 'center', width: "100px", sortable: true },
                    { field: 'ReturnYear', align: 'center', width: "100px", sortable: true },
                    { field: 'QZH', align: 'left', width: "100px", sortable: true },
                    { field: 'Term', align: 'center', width: "100px", sortable: true },
                    { field: 'StartDate', align: 'center', width: "100px", sortable: true },
                    { field: 'EndDate', align: 'center', width: "100px", sortable: true },
                    { field: 'ReturnDate', align: 'center', width: "100px", sortable: true },
                    { field: 'PageCount', align: 'center', width: "100px", sortable: true },
                    { field: 'ItemCount', align: 'center', width: "100px", sortable: true },
                    { field: 'SecretLevel', align: 'center', width: "100px", sortable: true },
                    { field: 'StorePlace', align: 'center', width: "100px", sortable: true },
                    { field: 'Remark', align: 'center', width: "100px", sortable: true },
                    { field: 'WriteTime', align: 'center', width: "200px", sortable: true, formatter: DateFormatter },
                ],
                onLoadError: function () { //加载失败事件
                    showTip("数据加载中，请等待！", 2);
                },
                onClickRow: function (row, obj) { //单击行事件
                    $(obj).parent().find("tr").removeClass("selected");
                    $(obj).addClass("selected");

                    //根据选中的行获取子表数据
                    GetSonData(row.Id);
                },
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr").each(function (z) {
                            $("td:not(.bs-checkbox)", this).each(function (i) {
                                if (i != 0) {
                                    var str = "<span class=\"bg-yellow\">" + text + "</span>";
                                    var NewText = $("#tabData tbody tr").eq(z).find("td").eq(i).text().replaceAll(text, str);
                                    $("#tabData tbody tr").eq(z).find("td").eq(i).html(NewText);
                                }
                            })
                        })
                    }
                }
            });
        })

        //请求服务数据时所传参数
        function queryParams(params) {
            return {
                pageSize: params.pageSize,      // 页数
                pageNumber: params.pageNumber,  // 页码
                sort: params.sort,              // 排序字段
                order: params.order,            // 升序、降序
                type: 'GetEquipmentList',       //方法名
                search: params.search,
                txtsearch: $("#txtSearch").val()
            }
        }

        //模糊查询功能
        function getTEquipmentList() {
            $("#tabData").bootstrapTable('refresh');
        }

        //执行回车不刷新页面
        document.onkeydown = function () {
            if (event.keyCode == 13) {
                $("#tabData").bootstrapTable('refresh');
                event.returnValue = false;
            }
        }


        //获取子表数据
        function GetSonData(_ParentID) {
            DataLoading();
            $.ajax({
                type: "post",
                url: "/ashx/Files.ashx",
                dataType: "json",
                async: true,
                data: { type: "GetTEquipmentSon", ParentID: _ParentID },
                success: function (msg) {
                    if (msg.result == 1) {
                        BindTab2(msg.JsonData);
                        $("#htmlTip").remove();
                    }
                }
            });
        }

        function BindTab2(JsonData) {
            $('#tabData2').bootstrapTable('destroy');
            $('#tabData2').bootstrapTable({
                height: tabHeight - 50,
                data: JsonData != "" ? JSON.parse(JsonData) : "",
                dataType: "json",
                columns: [
                    { align: 'center', width: "50px", checkbox: true },
                    { field: 'AJJDH', align: 'center', width: "120px", sortable: true },
                    { field: 'DH', align: 'center', width: "80px", sortable: true },
                    { field: 'SXH', align: 'center', width: "80px", sortable: true },
                    { field: 'Title', align: 'center', width: "150px", sortable: true },
                    { field: 'ZRZ', align: 'center', width: "150px", sortable: true },
                    { field: 'ThemeWord', align: 'center', width: "150px", sortable: true },
                    { field: 'FormDate', align: 'center', width: "150px", sortable: true },
                    { field: 'PageCount', align: 'center', width: "150px", sortable: true },
                    { field: 'ReturnDate', align: 'center', width: "150px", sortable: true },
                    { field: 'QZH', align: 'center', width: "150px", sortable: true },
                    { field: 'ReturnYear', align: 'center', width: "150px", sortable: true },
                    { field: 'XMH', align: 'center', width: "150px", sortable: true },
                    { field: 'STFLH', align: 'center', width: "150px", sortable: true },
                    { field: 'Term', align: 'center', width: "150px", sortable: true },
                    { field: 'AJH', align: 'center', width: "120px", sortable: true },
                    { field: 'ArticleNo', align: 'center', width: "150px", sortable: true },

                    { field: 'PageNo', align: 'center', width: "80px", sortable: true },

                    { field: 'LSH', align: 'center', width: "90px", sortable: true },
                    { field: 'SecretLevel', align: 'center', width: "120px", sortable: true },
                    { field: 'StorePlace', align: 'center', width: "80px", sortable: true },
                    { field: 'Mark', align: 'center', width: "80px", sortable: true },
                    { field: 'Remark', align: 'center', width: "80px", sortable: true },
                    { field: 'WriteTime', align: 'center', width: "90px", sortable: true, formatter: DateFormatter },
                ],
                //toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                //pageSize: 100,//分页条数
                clickToSelect: true,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: true,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "EquipmentGrandSon",//cookie键值
                pagination: false,//是否分页
                showColumns: false,//是否显示所有的列
                showRefresh: false,//是否显示刷新按钮
                search: false,//是否启用搜索
                showPaginationSwitch: false,//是否显示分页切换按钮
                showExport: false,//是否启用导出
                striped: false,//是否显示行间隔色
                exportOptions: {
                    ignoreColumn: [0],  //忽略某一列的索引
                },
                detailView: false,//是否显示切换视图列
                onDblClickRow: function (row, obj) { //双击行事件
                    //showPage('修改工程项目档案信息', '/scan3/EngDeviceSonEdit.aspx?ID=' + row.ID, 800, 550, true);
                    //location.href = "EngDeviceGrandSon.aspx?ParentID="row + (row.ID);
                    location.href = "EquipmentSon.aspx?ParentID=" + (row.Id) + "&DH=" + (row.DH);
                }
            });
        }
    </script>
}
